package com.zxy.furns.service.impl;

import com.zxy.furns.dao.MemberDAO;
import com.zxy.furns.dao.impl.MemberDAOImpl;
import com.zxy.furns.entity.Member;
import com.zxy.furns.service.MemberService;

/**
 * ClassName: MemberServiceImpl
 * Package: com.zxy.furns.service.impl
 *
 * @Author zxy
 * @Create 2025/3/20 21:50
 * @Version 1.0
 * title:
 * Description:
 */
public class MemberServiceImpl implements MemberService {
    private MemberDAO memberDAO = new MemberDAOImpl();


    @Override
    public boolean register(Member member) {
        int i = memberDAO.saveMember(member);
        if (i == 1) {
            //表示注册成功
            return true;
        } else {
            //表示注册失败
            return false;
        }
    }

    @Override
    public boolean isExistsUsername(String username) {
        Member member = memberDAO.queryMemberByUsername(username);
        if (member != null) {
            return true;//表示用户名存在
        } else {
            return false;
        }
    }

    @Override
    public Member login(Member member) {
        return memberDAO.queryMemberByUsernameAndPassword(member.getUsername(), member.getPassword());
    }
}
